import Vue from "vue"
import VueRouter from "vue-router"

//将路由注入所有子组件中
Vue.use(VueRouter)

//声明路由配置 Routes
let routes = [
    //路由懒加载，(按需加载)，主要通过import()这种语法，vue-cli是基于webpack、webpack编译的时候，遇到import()这种语法，就会自动将代码进行分割，split-code，实现懒加载的核心就是使用webpack的代码分割功能
        //懒加载的好处：提高首屏的加载速度，提升用户体验，节省流量
    {
        path:"/",
        redirect:"/list"

    },
    // {
    //     path:"/discover",
    //     redirect:"/discover/djradio",
        
    //     component: () => import(/*webpackChunkName:'discover*/"@/pages/discover" ),
    //     children:[
    //         {
    //             path:"djradio",
    //             component:()=>import("@/pages/discover/djradio")
    //         },
    //         {
    //             path:"palylist",
    //             component:()=>import("@/pages/discover/palylist")
    //         }
    //     ],
    // },
    {
        path:"/mine",
        component: () => import ( /*webpackChunkName:'mine*/"@/pages/mine" )
    },
    {
        path:"/list",
        component: () => import ( /*webpackChunkName:'list*/"@/pages/list" )
    },
    {
        path:"/detail",
        // props:true,
        component: () => import ( /*webpackChunkName:'detail*/"@/pages/detail" )
    },
    {
        path:"*",
        component: () => import ("@/pages/undef" )
    }
];

//实例化路由
let router = new VueRouter({
    routes
});

// 把路由导出去
export default router;
